# cython: language_level=3
import asyncio
from concurrent.futures import ThreadPoolExecutor, Future

async def incr(x):
    # 在这里编写您的异步逻辑
    # 这里只是一个示例，可以根据实际需求进行修改
    import time
    await asyncio.sleep(1)
    return x + 1

def run_in_thread(future, x):
    async def run_async():
        result = await incr(x)
        future.set_result(result)

    asyncio.run(run_async())

if __name__ == "__main__":
    executor = ThreadPoolExecutor(max_workers=1)
    future = Future()

    # 提交异步方法执行
    task = executor.submit(run_in_thread, future, 5)

    # 阻塞等待异步方法执行完成
    task.result()

    # 获取异步方法的返回值
    result = future.result()
    print(result)